<template>
  <div class="welcome">
    <div class="title">欢迎使用会议室预约管理系统</div>
    <div class="date-container">
      <div 
        v-for="(date, index) in weekDates" 
        :key="index" 
        class="date-item"
        :class="{ 'today': date.isToday }"
      >
        <div class="day-name">{{ date.dayName }}</div>
        <div class="day-number">{{ date.dayNumber }}</div>
        <div class="month">{{ date.month }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      weekDates: []
    }
  },
  created() {
    this.generateWeekDates();
  },
  methods: {
    generateWeekDates() {
      const days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
      const months = ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'];
      
      const today = new Date();
      const currentDay = today.getDay(); // 获取今天是星期几 (0-6)
      
      // 生成近一周的日期（包含当天）
      for (let i = 0; i < 7; i++) {
        const date = new Date();
        date.setDate(today.getDate() + (i - currentDay));
        
        this.weekDates.push({
          dayName: days[date.getDay()],
          dayNumber: date.getDate(),
          month: months[date.getMonth()],
          isToday: date.toDateString() === today.toDateString()
        });
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.welcome {
  position: relative;
  display: flex;
  height: 100%;
  background: url('@/assets/welcome_bg.jpg') no-repeat center / cover;
  background-size: 40% 50%;
  background-position: 85%;

  .title {
    color: #666;
    position: absolute;
    top: 20%;
    left: 10%;
    font-size: 30px;
  }

  .date-container {
    position: absolute;
    top: 30%;
    left: 10%;
    display: flex;
    gap: 20px;
  }

  .date-item {
    width: 60px;
    height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;

    &.today {
      background: #409eff;
      color: white;
      transform: scale(1.1);
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }

    .day-name {
      font-size: 14px;
      margin-bottom: 5px;
    }

    .day-number {
      font-size: 24px;
      font-weight: bold;
    }

    .month {
      font-size: 12px;
      margin-top: 5px;
    }
  }
}
</style>